#include<bits/stdc++.h>
using namespace std;

class StockPrice {
private:
    unordered_map<int, int>mp;
    multiset<int>st;
    int latest_time;
public:
    StockPrice() {
        this->latest_time = 0;
    }
    
    void update(int timestamp, int price) {
        latest_time = max(latest_time, timestamp);
        if(mp.count(timestamp)){
            st.erase(st.find(mp[timestamp]));
        }
        st.emplace(price);
        mp[timestamp] = price;
    }
    
    int current() {
        return mp[latest_time];
    }
    
    int maximum() {
        return *st.rbegin();
    }
    
    int minimum() {
        return *st.begin();
    }
};

/**
 * 2022.1.23
 * 注意 erase() 的参数为迭代器。
 */